﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Validation;
using System.ComponentModel.DataAnnotations;

namespace Skynet.BusinessEntities
{
    
    public class ProductMetadata
    {
        [Microsoft.Practices.EnterpriseLibrary.Validation.Validators.StringLengthValidator(5)]
        public string Name { get; set; }

        [System.ComponentModel.DataAnnotations.StringLength(5)]
        public string Description { get; set; }

        

    }

    [Microsoft.Practices.EnterpriseLibrary.Validation.Validators.HasSelfValidation]
    [MetadataType(typeof(ProductMetadata))]
    public class Product
    {
        
        public string Name { get; set; }

        
        public string Description { get; set; }

        [Microsoft.Practices.EnterpriseLibrary.Validation.Validators.SelfValidation]
        public void DoValidation(ValidationResults results)
        {
            if (!string.IsNullOrEmpty(this.Name) && Name.Contains("6"))
            {
                results.AddResult(new Microsoft.Practices.EnterpriseLibrary.Validation.ValidationResult("6 is not allow", this, "SixValidation", "", null));
            }
        }
        

    }
} 
